#!/usr/bin/env node

const router = require('koa-router')(),
      mysql = require('mysql2/promise'),
      {picture} = require('../models');

router.prefix('/pictures');

router.post('/upload',async(ctx,next)=>{
  let files=ctx.request.files.file;
  ctx.body = await picture.postPicture(files);
})

router.get('/getCount',async(ctx,next)=>{
  ctx.body = await picture.getCount();
})

router.get('/showPage',async (ctx,next)=>{
  const {page,limit} = ctx.query;
  ctx.body = await picture.showPagePicture(page,limit);
})

router.delete('/:id',async (ctx,next)=>{
  const {id} = ctx.params;
  ctx.body = await picture.deletePicture(id);
})
module.exports = router;
